﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Web;
using System.Globalization;

using iTextSharp;
using iTextSharp.text;
using iTextSharp.text.pdf;

using BusinessManagementStudio.Utilities.PDF_Templates;
using BusinessManagementStudio.Models.BusinessObject.Entities;

namespace BusinessManagementStudio.Utilities
{
    public static class PDFUtil
    {
        public static bool PDFCreation(String destPath, String destFileName, PDF_QuotationInvoice pdfQuotation)
        {
            bool isSuccess = false;
            int StandardFontSize = 9;
            int HeaderFontSizeChinese = 18;
            int HeaderFontSizeEnglish = 14;
            int StandardFontSize1 = 1;
            int StandardFontSize2 = 10;
            float StandardFontSize3 = 0.01f;
            int StandardFontSize8 = 8;
            int NoOfItems = (pdfQuotation.IsJLLOrderQuotation == true || pdfQuotation.IsJLLOrderInvoice == true) ? pdfQuotation.QuotationList.Count : pdfQuotation.QuotationList.Count;
            int NoOfPages = (int)Math.Ceiling((double)NoOfItems / (double)pdfQuotation.MaxNoOfRecords);

            var PDFDoc = new Document(PageSize.A4, 30, 30, 30, 20);
            PdfWriter pdfWriter = PdfWriter.GetInstance(PDFDoc, new FileStream(destPath + destFileName, FileMode.Create));

            try
            {
                PDFDoc.Open();
                Decimal TotalAmount = 0;

                for (int j = 0; j < NoOfPages; j++)
                {
                    PDFDoc.NewPage();

                    int currentPage = j + 1;

                    #region Part I - Company Info
                    PdfPTable pdfTable = new PdfPTable(2);
                    pdfTable.TotalWidth = 500f;
                    pdfTable.LockedWidth = true;
                    float[] widths = new float[] { 3f, 2f };
                    pdfTable.SetWidths(widths);

                    #region Row 1 - Company Name & Company Image
                    PdfPTable nestedTable = new PdfPTable(1);

                    PdfPCell HeaderCell1 = new PdfPCell(new Phrase(pdfQuotation.CompanyNameInChinese, CreateChineseFontWithBold(HeaderFontSizeChinese)));
                    HeaderCell1.HorizontalAlignment = Element.ALIGN_LEFT;
                    HeaderCell1.Border = PdfPCell.NO_BORDER;
                    nestedTable.AddCell(HeaderCell1);
                    PdfPCell HeaderCell2 = new PdfPCell(new Phrase(pdfQuotation.CompanyNameInEnglish, CreateEnglishFontWithBold(HeaderFontSizeEnglish)));
                    HeaderCell2.HorizontalAlignment = Element.ALIGN_LEFT;
                    HeaderCell2.Border = PdfPCell.NO_BORDER;
                    nestedTable.AddCell(HeaderCell2);
                    PdfPCell nesthousing = new PdfPCell(nestedTable);
                    nesthousing.Padding = 0f;
                    nesthousing.Border = PdfPCell.NO_BORDER;
                    pdfTable.AddCell(nesthousing);

                    Image jpg = Image.GetInstance(pdfQuotation.CompanyLogoPath);
                    jpg.ScaleAbsolute(140, 60);
                    PdfPCell imageCell = new PdfPCell(jpg);
                    imageCell.Border = PdfPCell.NO_BORDER;
                    imageCell.HorizontalAlignment = Element.ALIGN_RIGHT;
                    pdfTable.AddCell(imageCell);
                    #endregion

                    #region Row 2 - Empty Row
                    PdfPCell EmptyCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize)));
                    EmptyCell.HorizontalAlignment = Element.ALIGN_LEFT;
                    EmptyCell.Border = PdfPCell.BOTTOM_BORDER;
                    EmptyCell.Colspan = 2;
                    EmptyCell.BorderWidthBottom = 2f;
                    pdfTable.AddCell(EmptyCell);
                    #endregion

                    PDFDoc.Add(pdfTable);
                    Paragraph p = new Paragraph("\n");
                    PDFDoc.Add(p);
                    #endregion

                    #region Part II - Billing Info
                    PdfPTable BillInfoTable = new PdfPTable(4);
                    BillInfoTable.TotalWidth = 500f;
                    BillInfoTable.LockedWidth = true;
                    widths = new float[] { 1f, 4f, 2f, 2f };
                    BillInfoTable.SetWidths(widths);

                    if (pdfQuotation.IsQuotation == true && pdfQuotation.IsJLLOrderQuotation == true)
                    {
                        #region Row 1 - Bill To & Quotation No
                        PdfPCell cell = new PdfPCell(new Phrase("Bill To :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.client.BillingName, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Quot No. :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.QuotationNo, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 2 - Bill Address & Work Order No
                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.client.BillingAddress1, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Work Order :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.WorkOrderNo, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 3 - Bill Address & Quotation Date
                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.client.BillingAddress2, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Date :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.QuotationDate.ToString("dd-MMM-yyyy", CultureInfo.CreateSpecificCulture("en-US")), CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 4 - Bill Address & Pages
                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.client.BillingAddress3, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Page(s) :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        String tempPage = currentPage + " of " + NoOfPages;
                        cell = new PdfPCell(new Phrase(tempPage, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 5 - Reference No (Service Order No)
                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Ref :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.ReferenceNo, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 6 - Attention To & Vendor No
                        cell = new PdfPCell(new Phrase("Attn. :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.client.AttentionTo, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Vendor No. :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.VendorNo, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion
                    }
                    else if (pdfQuotation.IsInvoice == true && pdfQuotation.IsJLLOrderInvoice == true)
                    {
                        #region Row 1 - Bill To & Invoice No
                        PdfPCell cell = new PdfPCell(new Phrase("Bill To :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.client.BillingName, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Invoice No. :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.InvoiceNo, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 2 - Bill Address & Quotation No
                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.client.BillingAddress1, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Quot No. :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.QuotationNo, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 3 - Bill Address & Work Order No
                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.client.BillingAddress2, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Work Order :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.WorkOrderNo, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 4 - Bill Address & Invoice Date
                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.client.BillingAddress3, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Date :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.InvoiceDate.ToString("dd-MMM-yyyy", CultureInfo.CreateSpecificCulture("en-US")), CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 5 - Pages
                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Page(s) :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        String tempPage = currentPage + " of " + NoOfPages;
                        cell = new PdfPCell(new Phrase(tempPage, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 6 - Attention To & Reference No (Service Order No)
                        cell = new PdfPCell(new Phrase("Attn. :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.client.AttentionTo, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Ref :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.ReferenceNo, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 7 - Vendor No
                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Vendor No. :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.VendorNo, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion
                    }
                    else if (pdfQuotation.IsQuotation == true && pdfQuotation.IsJLLPOQuotation == true)
                    {
                        #region Row 1 - Bill To & Quotation No
                        PdfPCell cell = new PdfPCell(new Phrase("Bill To :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.client.BillingName, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Quot No. :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        String[] split = pdfQuotation.QuotationNo.Split('-');
                        String tempQuotationNo = split[0] + "-" + split[1] + "/" + split[2] + "/" + split[3];
                        cell = new PdfPCell(new Phrase(tempQuotationNo, CreateFont(StandardFontSize)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 2 - Bill Address & Quotation Date
                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.client.BillingAddress1, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Date :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.QuotationDate.ToString("dd-MMM-yyyy", CultureInfo.CreateSpecificCulture("en-US")), CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 3 - Bill Address & Pages
                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.client.BillingAddress2, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Page(s) :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        String tempPage = currentPage + " of " + NoOfPages;
                        cell = new PdfPCell(new Phrase(tempPage, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 4 - Bill Address & Reference No (Service Order No)
                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.client.BillingAddress3, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Ref :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.ReferenceNo, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 5 - Vendor No
                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Vendor No. :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.VendorNo, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 6 - Attention To
                        cell = new PdfPCell(new Phrase("Attn. :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.client.AttentionTo, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion
                    }
                    else if (pdfQuotation.IsInvoice == true && pdfQuotation.IsJLLPOInvoce == true)
                    {
                        #region Row 1 - Bill To & Invoice No
                        PdfPCell cell = new PdfPCell(new Phrase("Bill To :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.client.BillingName, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Invoice No. :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.InvoiceNo, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 2 - Bill Address & Invoice Date
                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.client.BillingAddress1, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Date :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.InvoiceDate.ToString("dd-MMM-yyyy", CultureInfo.CreateSpecificCulture("en-US")), CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 3 - Bill Address & Purchase Order No
                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.client.BillingAddress2, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Purchase Order :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.PONo, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 4 - Bill Address & Work Order No
                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.client.BillingAddress3, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Work Order :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.WorkOrderNo, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 5 - Pages
                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Page(s) :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        String tempPage = currentPage + " of " + NoOfPages;
                        cell = new PdfPCell(new Phrase(tempPage, CreateFont(StandardFontSize)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 6 - Attention To & Reference No (Quotation No)
                        cell = new PdfPCell(new Phrase("Attn. :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.client.AttentionTo, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Ref :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.ReferenceNo, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion

                        #region Row 7 - Vendor No
                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("Vendor No. :", CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);

                        cell = new PdfPCell(new Phrase(pdfQuotation.VendorNo, CreateFont(StandardFontSize2)));
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        cell.Border = PdfPCell.NO_BORDER;
                        BillInfoTable.AddCell(cell);
                        #endregion
                    }

                    PDFDoc.Add(BillInfoTable);
                    p = new Paragraph("\n");
                    PDFDoc.Add(p);
                    #endregion

                    #region Part III - Quotation / Invoice
                    PdfPTable qTable = new PdfPTable(1);
                    qTable.TotalWidth = 500f;
                    qTable.LockedWidth = true;
                    #region Section Header
                    PdfPCell hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    hCell.Border = PdfPCell.TOP_BORDER;
                    qTable.AddCell(hCell);

                    if (pdfQuotation.IsQuotation == true)
                    {
                        hCell = new PdfPCell(new Phrase("QUOTATION", CreateEnglishFontWithBold(HeaderFontSizeChinese)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.TOP_BORDER;
                        qTable.AddCell(hCell);
                    }
                    else if (pdfQuotation.IsInvoice == true)
                    {
                        hCell = new PdfPCell(new Phrase("INVOICE", CreateEnglishFontWithBold(HeaderFontSizeChinese)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.TOP_BORDER;
                        qTable.AddCell(hCell);
                    }

                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    hCell.Border = PdfPCell.BOTTOM_BORDER;
                    qTable.AddCell(hCell);

                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    hCell.Border = PdfPCell.BOTTOM_BORDER;
                    qTable.AddCell(hCell);

                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    hCell.Border = PdfPCell.NO_BORDER;
                    qTable.AddCell(hCell);
                    #endregion

                    PDFDoc.Add(qTable);

                    #region Service Address
                    PdfPTable SATable = new PdfPTable(2);
                    SATable.TotalWidth = 500f;
                    SATable.LockedWidth = true;
                    widths = new float[] { 0.3f, 5f };
                    SATable.SetWidths(widths);

                    hCell = new PdfPCell(new Phrase("RE :", CreateEnglishFontWithBold(StandardFontSize2)));
                    hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                    hCell.Border = PdfPCell.NO_BORDER;
                    SATable.AddCell(hCell);

                    String tStrn = pdfQuotation.Location + " - " + pdfQuotation.ServiceDetail;

                    if(pdfQuotation.ServiceDetail == "" || pdfQuotation.ServiceDetail == null)
                        tStrn = pdfQuotation.Location;

                    hCell = new PdfPCell(new Phrase(tStrn, CreateFontWithBoldAndUnderline(StandardFontSize2)));
                    hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                    hCell.Border = PdfPCell.NO_BORDER;
                    SATable.AddCell(hCell);

                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    hCell.Border = PdfPCell.NO_BORDER;
                    SATable.AddCell(hCell);

                    PDFDoc.Add(SATable);
                    p = new Paragraph("\n");
                    PDFDoc.Add(p);
                    #endregion

                    #region Quotation / Invoice Header
                    PdfPTable QuotationTable = new PdfPTable(7);
                    QuotationTable.TotalWidth = 500f;
                    QuotationTable.LockedWidth = true;
                    widths = new float[] { 1f, 5f, 1f, 1f, 1f, 2f, 2f };
                    QuotationTable.SetWidths(widths);

                    #region Row 1 - Header
                    hCell = new PdfPCell(new Phrase("Item", CreateFontWithBoldAndUnderline(StandardFontSize2)));
                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    hCell.Border = PdfPCell.NO_BORDER;
                    QuotationTable.AddCell(hCell);

                    hCell = new PdfPCell(new Phrase("Description", CreateFontWithBoldAndUnderline(StandardFontSize2)));
                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    hCell.Border = PdfPCell.NO_BORDER;
                    QuotationTable.AddCell(hCell);

                    hCell = new PdfPCell(new Phrase("SOR Item", CreateFontWithBoldAndUnderline(StandardFontSize2)));
                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    hCell.Border = PdfPCell.NO_BORDER;
                    QuotationTable.AddCell(hCell);

                    hCell = new PdfPCell(new Phrase("Qty", CreateFontWithBoldAndUnderline(StandardFontSize2)));
                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    hCell.Border = PdfPCell.NO_BORDER;
                    QuotationTable.AddCell(hCell);

                    hCell = new PdfPCell(new Phrase("Unit", CreateFontWithBoldAndUnderline(StandardFontSize2)));
                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    hCell.Border = PdfPCell.NO_BORDER;
                    QuotationTable.AddCell(hCell);

                    hCell = new PdfPCell(new Phrase("Rate", CreateFontWithBoldAndUnderline(StandardFontSize2)));
                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    hCell.Border = PdfPCell.NO_BORDER;
                    QuotationTable.AddCell(hCell);

                    hCell = new PdfPCell(new Phrase("Amount (HKD)", CreateFontWithBoldAndUnderline(StandardFontSize2)));
                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    hCell.Border = PdfPCell.NO_BORDER;
                    QuotationTable.AddCell(hCell);
                    #endregion

                    #region Row 2 - Empty Row / Brought Forward
                    if (j >= 1 && j < NoOfPages)
                    {
                        #region Brought Forward
                        hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        QuotationTable.AddCell(hCell);

                        hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        QuotationTable.AddCell(hCell);

                        hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        QuotationTable.AddCell(hCell);

                        hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        QuotationTable.AddCell(hCell);

                        hCell = new PdfPCell(new Phrase("Brought Forward:", CreateFont(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        hCell.Colspan = 2;
                        QuotationTable.AddCell(hCell);

                        hCell = new PdfPCell(new Phrase(TotalAmount.ToString("#,##0.00"), CreateFont(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.BOTTOM_BORDER;
                        QuotationTable.AddCell(hCell);
                        #endregion

                        #region Empty Row
                        hCell = new PdfPCell(new Phrase("\n", CreateFontWithBoldAndUnderline(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        hCell.Colspan = 7;
                        QuotationTable.AddCell(hCell);
                        #endregion
                    }
                    else
                    {
                        #region Empty Row
                        hCell = new PdfPCell(new Phrase("\n", CreateFontWithBoldAndUnderline(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        hCell.Colspan = 7;
                        QuotationTable.AddCell(hCell);
                        #endregion
                    }
                    #endregion

                    int StartIndex = GetStartIndex(pdfQuotation, j);
                    int EndIndex = GetEndIndex(pdfQuotation, currentPage, NoOfPages);
                    String tempStrn = "";
                    #region Row 3 onwards - Item List
                    if (pdfQuotation.IsJLLOrderQuotation == true || pdfQuotation.IsJLLOrderInvoice == true)
                    {
                        #region JLLOrder Item
                        //foreach (JLLOrderQuotation JOItem in pdfQuotation.JOQuotationList)
                        for (int sIndex = StartIndex; sIndex < EndIndex; sIndex++ )
                        {
                            tempStrn = (pdfQuotation.QuotationList[sIndex].ItemNo == 0) ? "" : pdfQuotation.QuotationList[sIndex].ItemNo.ToString("00") + ".";
                            hCell = new PdfPCell(new Phrase(tempStrn, CreateFont(StandardFontSize2)));
                            hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                            hCell.Border = PdfPCell.NO_BORDER;
                            QuotationTable.AddCell(hCell);

                            hCell = new PdfPCell(new Phrase(pdfQuotation.QuotationList[sIndex].Description, CreateFont(StandardFontSize2)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.NO_BORDER;
                            QuotationTable.AddCell(hCell);

                            hCell = new PdfPCell(new Phrase(pdfQuotation.QuotationList[sIndex].SORItem, CreateFontWithUnderline(StandardFontSize2)));
                            hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                            hCell.Border = PdfPCell.NO_BORDER;
                            QuotationTable.AddCell(hCell);

                            tempStrn = (pdfQuotation.QuotationList[sIndex].Qty == 0) ? "" : pdfQuotation.QuotationList[sIndex].Qty.ToString("0");
                            hCell = new PdfPCell(new Phrase(tempStrn, CreateFont(StandardFontSize2)));
                            hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                            hCell.Border = PdfPCell.NO_BORDER;
                            QuotationTable.AddCell(hCell);

                            hCell = new PdfPCell(new Phrase(pdfQuotation.QuotationList[sIndex].Unit, CreateFont(StandardFontSize2)));
                            hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                            hCell.Border = PdfPCell.NO_BORDER;
                            QuotationTable.AddCell(hCell);

                            tempStrn = (pdfQuotation.QuotationList[sIndex].Rate == 0) ? "" : pdfQuotation.QuotationList[sIndex].Rate.ToString("#,##0.00");
                            hCell = new PdfPCell(new Phrase(tempStrn, CreateFont(StandardFontSize2)));
                            hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                            hCell.Border = PdfPCell.NO_BORDER;
                            QuotationTable.AddCell(hCell);

                            tempStrn = (pdfQuotation.QuotationList[sIndex].Amount == 0) ? "" : pdfQuotation.QuotationList[sIndex].Amount.ToString("#,##0.00");
                            hCell = new PdfPCell(new Phrase(tempStrn, CreateFont(StandardFontSize2)));
                            hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                            hCell.Border = PdfPCell.NO_BORDER;
                            QuotationTable.AddCell(hCell);

                            TotalAmount += pdfQuotation.QuotationList[sIndex].Amount;
                        }
                        #endregion
                    }
                    else if (pdfQuotation.IsJLLPOQuotation == true || pdfQuotation.IsJLLPOInvoce == true)
                    {
                        #region JLLPO Item
                        //foreach (JLLPOQuotation JPOItem in pdfQuotation.JPOQuotationList)
                        for (int sIndex = StartIndex; sIndex < EndIndex; sIndex++ )
                        {
                            tempStrn = (pdfQuotation.QuotationList[sIndex].ItemNo == 0) ? "" : pdfQuotation.QuotationList[sIndex].ItemNo.ToString("00") + ".";
                            hCell = new PdfPCell(new Phrase(tempStrn, CreateFont(StandardFontSize2)));
                            hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                            hCell.Border = PdfPCell.NO_BORDER;
                            QuotationTable.AddCell(hCell);

                            hCell = new PdfPCell(new Phrase(pdfQuotation.QuotationList[sIndex].Description, CreateFont(StandardFontSize2)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.NO_BORDER;
                            QuotationTable.AddCell(hCell);

                            hCell = new PdfPCell(new Phrase(pdfQuotation.QuotationList[sIndex].SORItem, CreateFontWithUnderline(StandardFontSize2)));
                            hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                            hCell.Border = PdfPCell.NO_BORDER;
                            QuotationTable.AddCell(hCell);

                            tempStrn = (pdfQuotation.QuotationList[sIndex].Qty == 0) ? "" : pdfQuotation.QuotationList[sIndex].Qty.ToString("0");
                            hCell = new PdfPCell(new Phrase(tempStrn, CreateFont(StandardFontSize2)));
                            hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                            hCell.Border = PdfPCell.NO_BORDER;
                            QuotationTable.AddCell(hCell);

                            hCell = new PdfPCell(new Phrase(pdfQuotation.QuotationList[sIndex].Unit, CreateFont(StandardFontSize2)));
                            hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                            hCell.Border = PdfPCell.NO_BORDER;
                            QuotationTable.AddCell(hCell);

                            tempStrn = (pdfQuotation.QuotationList[sIndex].Rate == 0) ? "" : pdfQuotation.QuotationList[sIndex].Rate.ToString("#,##0.00");
                            hCell = new PdfPCell(new Phrase(tempStrn, CreateFont(StandardFontSize2)));
                            hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                            hCell.Border = PdfPCell.NO_BORDER;
                            QuotationTable.AddCell(hCell);

                            tempStrn = (pdfQuotation.QuotationList[sIndex].Amount == 0) ? "" : pdfQuotation.QuotationList[sIndex].Amount.ToString("#,##0.00");
                            hCell = new PdfPCell(new Phrase(tempStrn, CreateFont(StandardFontSize2)));
                            hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                            hCell.Border = PdfPCell.NO_BORDER;
                            QuotationTable.AddCell(hCell);

                            TotalAmount += pdfQuotation.QuotationList[sIndex].Amount;
                        }
                        #endregion
                    }
                    #endregion

                    #region 2nd Last Row - Empty Row
                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    hCell.Border = PdfPCell.NO_BORDER;
                    QuotationTable.AddCell(hCell);

                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    hCell.Border = PdfPCell.NO_BORDER;
                    QuotationTable.AddCell(hCell);

                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    hCell.Border = PdfPCell.NO_BORDER;
                    QuotationTable.AddCell(hCell);

                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    hCell.Border = PdfPCell.NO_BORDER;
                    QuotationTable.AddCell(hCell);

                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    hCell.Border = PdfPCell.NO_BORDER;
                    QuotationTable.AddCell(hCell);

                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    hCell.Border = PdfPCell.NO_BORDER;
                    QuotationTable.AddCell(hCell);

                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    hCell.Border = PdfPCell.BOTTOM_BORDER;
                    QuotationTable.AddCell(hCell);
                    #endregion

                    if (currentPage == NoOfPages)
                    {
                        #region 2nd Last Row - Total Amount
                        hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        QuotationTable.AddCell(hCell);

                        hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        QuotationTable.AddCell(hCell);

                        hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        QuotationTable.AddCell(hCell);

                        hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        QuotationTable.AddCell(hCell);

                        hCell = new PdfPCell(new Phrase("Total Amount:", CreateFont(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        hCell.Colspan = 2;
                        QuotationTable.AddCell(hCell);

                        hCell = new PdfPCell(new Phrase(TotalAmount.ToString("#,##0.00"), CreateFont(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.BOTTOM_BORDER;
                        QuotationTable.AddCell(hCell);
                        #endregion

                        #region Last row
                        hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        hCell.Colspan = 6;
                        QuotationTable.AddCell(hCell);

                        hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.BOTTOM_BORDER;
                        QuotationTable.AddCell(hCell);
                        #endregion
                    }
                    else
                    {
                        #region 2nd Last Row - Carry Forward
                        hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        QuotationTable.AddCell(hCell);

                        hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        QuotationTable.AddCell(hCell);

                        hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        QuotationTable.AddCell(hCell);

                        hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        QuotationTable.AddCell(hCell);

                        hCell = new PdfPCell(new Phrase("Carry Forward:", CreateFont(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        hCell.Colspan = 2;
                        QuotationTable.AddCell(hCell);

                        hCell = new PdfPCell(new Phrase(TotalAmount.ToString("#,##0.00"), CreateFont(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.BOTTOM_BORDER;
                        QuotationTable.AddCell(hCell);
                        #endregion

                        #region Last row
                        hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        hCell.Colspan = 6;
                        QuotationTable.AddCell(hCell);

                        hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.BOTTOM_BORDER;
                        QuotationTable.AddCell(hCell);
                        #endregion
                    }

                    #region Work Completion Date
                    //if (pdfQuotation.IsJLLOrderQuotation == true || pdfQuotation.IsJLLOrderInvoice == true)
                    //{
                    if (currentPage == NoOfPages)
                    {
                        String tempWrkCompletionDate = "Work completion on " + pdfQuotation.WorkCompletionDate.ToString("dd MMMM yyyy", CultureInfo.CreateSpecificCulture("en-US"));
                        hCell = new PdfPCell(new Phrase(tempWrkCompletionDate, CreateFont(StandardFontSize2)));
                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                        hCell.Border = PdfPCell.NO_BORDER;
                        hCell.Colspan = 7;
                        QuotationTable.AddCell(hCell);

                        int NoOfItemsOfLastPage = GetNoOfItems(pdfQuotation, StartIndex, EndIndex);
                        int tempFontSize = GetFontSize(NoOfItemsOfLastPage, StandardFontSize2, StandardFontSize1);

                        hCell = new PdfPCell(new Phrase("\n", CreateFont(tempFontSize)));
                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                        hCell.Border = PdfPCell.NO_BORDER;
                        hCell.Colspan = 7;
                        QuotationTable.AddCell(hCell);

                        hCell = new PdfPCell(new Phrase("\n", CreateFont(tempFontSize)));
                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                        hCell.Border = PdfPCell.NO_BORDER;
                        hCell.Colspan = 7;
                        QuotationTable.AddCell(hCell);
                    }
                    //}
                    #endregion
                    #endregion

                    PDFDoc.Add(QuotationTable);
                    //p = new Paragraph("\n");
                    //PDFDoc.Add(p);
                    #endregion

                    // Check if the current page is the last page
                    if (currentPage == NoOfPages)
                    {
                        int NoOfItemsOfLastPage = GetNoOfItems(pdfQuotation, StartIndex, EndIndex);
                        int NoOfLines = GetNoOfLines(NoOfItemsOfLastPage, currentPage);
                        int tempFontSize = GetFontSize(NoOfItemsOfLastPage, StandardFontSize2, StandardFontSize1, currentPage);

                        p = new Paragraph("\n");
                        for (int i = 0; i < NoOfLines; i++)
                            PDFDoc.Add(p);

                        #region Part IV - Remarks
                        PdfPTable RemarkTable = new PdfPTable(2);
                        RemarkTable.TotalWidth = 500f;
                        RemarkTable.LockedWidth = true;

                        if (pdfQuotation.IsQuotation == true)
                        {
                            widths = new float[] { 0.2f, 4f };
                            RemarkTable.SetWidths(widths);

                            #region Row 1 - Remark Header
                            hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize8)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.NO_BORDER;
                            RemarkTable.AddCell(hCell);

                            hCell = new PdfPCell(new Phrase("Remarks:", CreateFont(StandardFontSize8)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.NO_BORDER;
                            RemarkTable.AddCell(hCell);
                            #endregion

                            #region Row 2 - Remark a
                            hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize8)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.NO_BORDER;
                            RemarkTable.AddCell(hCell);

                            hCell = new PdfPCell(new Phrase("a) Quotation Validity: 30 days from the date of this quotation", CreateFont(StandardFontSize8)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.NO_BORDER;
                            RemarkTable.AddCell(hCell);
                            #endregion

                            #region Row 3 - Remark b
                            hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize8)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.NO_BORDER;
                            RemarkTable.AddCell(hCell);

                            hCell = new PdfPCell(new Phrase("b) Please sign and return for order confirmation if the above quotation is acceptable for you", CreateFont(StandardFontSize8)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.NO_BORDER;
                            RemarkTable.AddCell(hCell);
                            #endregion
                        }
                        else if (pdfQuotation.IsInvoice == true)
                        {
                            #region Row 1 - Remark Header
                            String tempString = "** Say Hong Kong Dollars " + NumberUtil.changeCurrencyToWords((double)TotalAmount) + " **";

                            hCell = new PdfPCell(new Phrase(tempString, CreateFont(StandardFontSize2)));
                            hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                            hCell.Border = PdfPCell.NO_BORDER;
                            hCell.Colspan = 2;
                            RemarkTable.AddCell(hCell);
                            #endregion
                        }

                        #region Row 4 - Empty Row
                        hCell = new PdfPCell(new Phrase("\n", CreateFont(tempFontSize)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        hCell.Colspan = 2;
                        RemarkTable.AddCell(hCell);
                        #endregion

                        #region Row 5 - Empty Row
                        hCell = new PdfPCell(new Phrase("\n", CreateFont(tempFontSize)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        hCell.Colspan = 2;
                        RemarkTable.AddCell(hCell);
                        #endregion

                        #region Row 6 - Empty Row
                        hCell = new PdfPCell(new Phrase("\n", CreateFont(tempFontSize)));
                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
                        hCell.Border = PdfPCell.NO_BORDER;
                        hCell.Colspan = 2;
                        RemarkTable.AddCell(hCell);
                        #endregion

                        PDFDoc.Add(RemarkTable);
                        #endregion

                        #region Part V - Company Signature & Extra Information
                        PdfPTable ComSignTable = new PdfPTable(8);
                        ComSignTable.TotalWidth = 500f;
                        ComSignTable.LockedWidth = true;
                        widths = new float[] { 1f, 3f, 3f, 1f, 1f, 1f, 1f, 2f };
                        ComSignTable.SetWidths(widths);

                        if (pdfQuotation.IsQuotation == true)
                        {
                            #region Row 1 - Header Info
                            hCell = new PdfPCell(new Phrase("For and on behalf of", CreateEnglishFontWithBold(StandardFontSize)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.NO_BORDER;
                            hCell.Colspan = 8;
                            ComSignTable.AddCell(hCell);
                            #endregion

                            #region Row 2 - Header Info 2
                            hCell = new PdfPCell(new Phrase("Chung Kai Decoration Works Ltd.", CreateEnglishFontWithBold(StandardFontSize)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.NO_BORDER;
                            hCell.Colspan = 5;
                            ComSignTable.AddCell(hCell);

                            hCell = new PdfPCell(new Phrase("Confirmed and accepted by:", CreateEnglishFontWithBold(StandardFontSize)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.NO_BORDER;
                            hCell.Colspan = 3;
                            ComSignTable.AddCell(hCell);
                            #endregion

                            #region Row 3 - Signature
                            jpg = Image.GetInstance(pdfQuotation.CompanySignaturePath);
                            jpg.ScaleAbsolute(60, 60);
                            imageCell = new PdfPCell(jpg);
                            imageCell.Border = PdfPCell.NO_BORDER;
                            imageCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            imageCell.Colspan = 8;
                            ComSignTable.AddCell(imageCell);
                            #endregion

                            #region Row 4 - Empty Row
                            hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize3)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.NO_BORDER;
                            hCell.Colspan = 8;
                            ComSignTable.AddCell(hCell);
                            #endregion

                            #region Row 5 - Signature Name
                            hCell = new PdfPCell(new Phrase("Authorised Signature", CreateEnglishFontWithBold(StandardFontSize)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.TOP_BORDER;
                            hCell.Colspan = 2;
                            ComSignTable.AddCell(hCell);

                            hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.NO_BORDER;
                            hCell.Colspan = 3;
                            ComSignTable.AddCell(hCell);

                            hCell = new PdfPCell(new Phrase("Signature & Company Chop.", CreateEnglishFontWithBold(StandardFontSize)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.TOP_BORDER;
                            hCell.Colspan = 3;
                            ComSignTable.AddCell(hCell);
                            #endregion
                        }
                        else if (pdfQuotation.IsInvoice == true)
                        {
                            #region Row 1 - Header Info
                            hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.NO_BORDER;
                            hCell.Colspan = 5;
                            ComSignTable.AddCell(hCell);

                            hCell = new PdfPCell(new Phrase("For and on behalf of", CreateEnglishFontWithBold(StandardFontSize)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.NO_BORDER;
                            hCell.Colspan = 3;
                            ComSignTable.AddCell(hCell);
                            #endregion

                            #region Row 2 - Header Info 2
                            hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.NO_BORDER;
                            hCell.Colspan = 5;
                            ComSignTable.AddCell(hCell);

                            hCell = new PdfPCell(new Phrase("Chung Kai Decoration Works Ltd.", CreateEnglishFontWithBold(StandardFontSize)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.NO_BORDER;
                            hCell.Colspan = 3;
                            ComSignTable.AddCell(hCell);
                            #endregion

                            #region Row 3 - Empty Rows
                            for (int i = 0; i < 5; i++)
                            {
                                hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize)));
                                hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                                hCell.Border = PdfPCell.NO_BORDER;
                                hCell.Colspan = 8;
                                ComSignTable.AddCell(hCell);
                            }
                            #endregion

                            #region Row 4 - Signature Name
                            hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.NO_BORDER;
                            hCell.Colspan = 5;
                            ComSignTable.AddCell(hCell);

                            hCell = new PdfPCell(new Phrase("Authorised Signature", CreateEnglishFontWithBold(StandardFontSize)));
                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                            hCell.Border = PdfPCell.TOP_BORDER;
                            hCell.Colspan = 3;
                            ComSignTable.AddCell(hCell);
                            #endregion
                        }

                        #region Row 6 - Empty Row
                        hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize)));
                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                        hCell.Border = PdfPCell.NO_BORDER;
                        hCell.Colspan = 8;
                        ComSignTable.AddCell(hCell);
                        #endregion

                        #region Row 7 - Empty Row
                        hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize)));
                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                        hCell.Border = PdfPCell.BOTTOM_BORDER;
                        hCell.BorderWidthBottom = 2f;
                        hCell.Colspan = 8;
                        ComSignTable.AddCell(hCell);
                        #endregion

                        #region Row 8 - Company Address Chinese
                        hCell = new PdfPCell(new Phrase(pdfQuotation.CompanyAddressInChinese, CreateFont(StandardFontSize8, true)));
                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                        hCell.Border = PdfPCell.NO_BORDER;
                        hCell.Colspan = 8;
                        ComSignTable.AddCell(hCell);
                        #endregion

                        #region Row 9 - Company Address English
                        hCell = new PdfPCell(new Phrase(pdfQuotation.CompanyAddressInEnglish, CreateFont(StandardFontSize8)));
                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                        hCell.Border = PdfPCell.NO_BORDER;
                        hCell.Colspan = 8;
                        ComSignTable.AddCell(hCell);
                        #endregion

                        #region Row 10 - Company Extra Info
                        hCell = new PdfPCell(new Phrase(pdfQuotation.CompanyExtraInfo, CreateFont(StandardFontSize8)));
                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
                        hCell.Border = PdfPCell.NO_BORDER;
                        hCell.Colspan = 8;
                        ComSignTable.AddCell(hCell);
                        #endregion

                        PDFDoc.Add(ComSignTable);
                        #endregion
                    }
                }
                PDFDoc.Close();
                isSuccess = true;
            }
            catch (Exception e)
            {
            }

            return isSuccess;
        }

        private static int GetNoOfLines(int NoOfItems, int CurrentPage = 1)
        {
            int result = 7;

            if ((NoOfItems >= 3 && NoOfItems <= 13) || CurrentPage > 1)
                result = 4;
            else if (NoOfItems > 13)
                result = 0;

            return result;
        }

        private static int GetFontSize(int NoOfItems, int BigFontSize, int SmallFontSize, int CurrentPage = 1)
        {
            int result = BigFontSize;

            if ((NoOfItems >= 6 && NoOfItems <= 13) || CurrentPage > 1)
                result = SmallFontSize;

            return result;
        }

        private static int GetNoOfItems(PDF_QuotationInvoice pdfQuotation, int StartIndex, int EndIndex)
        {
            List<Quotation> tempList = new List<Quotation>();

            for (int i = StartIndex; i < EndIndex; i++)
                tempList.Add(pdfQuotation.QuotationList[i]);

            return tempList.Count;
        }

        private static int GetStartIndex(PDF_QuotationInvoice pdfQuotation, int currentPageNo)
        {
            return currentPageNo * pdfQuotation.MaxNoOfRecords;
        }

        private static int GetEndIndex(PDF_QuotationInvoice pdfQuotation, int currentPageNo, int NoOfPages)
        {
            int ResultIndex = (currentPageNo * pdfQuotation.MaxNoOfRecords);

            if (currentPageNo == NoOfPages)
            {
                if(pdfQuotation.IsJLLOrderQuotation == true || pdfQuotation.IsJLLOrderInvoice == true)
                    ResultIndex = pdfQuotation.QuotationList.Count;
                else if (pdfQuotation.IsJLLPOQuotation == true || pdfQuotation.IsJLLPOInvoce == true)
                    ResultIndex = pdfQuotation.QuotationList.Count;
            }

            return ResultIndex;
        }

        public static Font CreateFont(float FontSize, bool isChinese = false)
        {
            BaseFont baseFT = BaseFont.CreateFont(Configuration.CompanyFontForEng, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            if(isChinese == true)
                baseFT = BaseFont.CreateFont(Configuration.CompanyFontForChi, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

            Font font = new Font(baseFT, FontSize);
            return font;
        }

        public static Font CreateEnglishFontWithBold(float FontSize)
        {
            BaseFont baseFT = BaseFont.CreateFont(Configuration.CompanyFontForEng, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            Font font = new Font(baseFT, FontSize, Font.BOLD);
            return font;
        }

        public static Font CreateChineseFontWithBold(float FontSize)
        {
            BaseFont baseFT = BaseFont.CreateFont(Configuration.CompanyFontForChi, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            Font font = new Font(baseFT, FontSize, Font.BOLD);
            return font;
        }

        public static Font CreateFontWithBoldAndUnderline(int FontSize, bool isChinese = false)
        {
            BaseFont baseFT = BaseFont.CreateFont(Configuration.CompanyFontForEng, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            if (isChinese == true)
                baseFT = BaseFont.CreateFont(Configuration.CompanyFontForChi, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

            Font font = new Font(baseFT, FontSize, Font.BOLD | Font.UNDERLINE);
            return font;
        }

        public static Font CreateFontWithUnderline(float FontSize)
        {
            BaseFont baseFT = BaseFont.CreateFont(Configuration.CompanyFontForEng, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            Font font = new Font(baseFT, FontSize, Font.UNDERLINE);
            return font;
        }
    }
}